<template>
  <div class="main">
    <div class="main-w">
      <div class="pd05 bs06 clearfix mb20" style="  height: 18px;line-height: 18px;"><a href="javascript:;" class="fr ico_download">下载全部列表</a><span class="ico_tips2"></span>您可以在线查看近一年订单，如需查找更久之前的订单，请至旅行app或致电95010</div>
      <div class="order_tab_box">
        <div class="order_tab"><a href="javascript:;" rel="noopener referrer" class="current">全部订单</a><a href="javascript:;" rel="noopener referrer" class="">未出行</a><a href="javascript:;" rel="noopener referrer" class="">待支付</a><a href="javascript:;" rel="noopener referrer" class="">待点评</a></div>
        <div class="mod_sort"></div>
      </div>
      <div class="orders_list mb20">
        <ul class="t_body">
          <div v-for="(order,index) in orderInfo" :key="order.order_id">
            <li class="item" v-if="(page-1)*10<=index&&index<page*10">
              <h3><label class="base_label"><input type="checkbox" name=""></label><span role="presentation" class="ilb mr20">订单号：<span class="card-order-id order-btn">{{order.order_id}}</span></span><span class="ilb mr20">预订日期：{{order.createtime.slice(0,10)}}</span></h3>
              <div role="presentation" class="order-items clearfix order-btn">
                <div class="order-info clearfix">
                  <ul class="order-item">
                    <li class="order-item-title"><span style="overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; display: -webkit-box; -webkit-line-clamp: 2;">{{JSON.parse(orderInfo[0].detail_info).name}}</span></li>
                    <li class="order-item-txt"><span>{{JSON.parse(orderInfo[0].detail_info).address}}</span></li>
                    <li class="order-item-txt"><span>{{JSON.parse(orderInfo[0].detail_info).grade}}</span></li>
                    <li class="order-item-txt"><span>入住人: {{order.name}}</span></li>
                    <li class="order-item-txt"><span>{{order.rooms_name}}</span></li>
                  </ul>
                </div>
                <div class="order-price-group">
                  <div class="order-price-detail">
                    <div class="order-price-num">¥{{order.min_price}}</div>
                  </div>
                  <div class="order-price-status">
                    <div class="order-price-status-title">{{order.pay_status==1?'已支付':'未支付'}}</div>
                  </div>
                </div>
              </div>
              <ul class="btns">
                <li role="presentation" class="btn" @click="del(order.order_id)"><span>
                    <p>删除订单</p>
                  </span></li>
              </ul>
            </li>
          </div>
        </ul>
        <div class="t_foot">
          <el-pagination background layout="prev, pager, next" :total="length" style="text-align:right" @current-change="handleCurrentChange">
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'MyOrder',
  data() {
    return {
      page: 1
    }
  },
  computed: {
    ...mapState({
      orderInfo: state => {
        return state.order.orderInfo
      },
      length: state => {
        return state.order.orderInfo.length
      }
    })
  },
  methods: {
    del(id) {
      // console.log(id)
      let phone = localStorage.getItem('user_phone')
      this.$store.dispatch('delOrder', id)
      this.$store.dispatch('getOrderInfo', phone)
    },
    handleCurrentChange(val) {
      this.page = val
      console.log(this.page)
    }
  }
}
</script>

<style lang="scss" scoped>
.main {
  padding: 10px 0 10px 8px;
  margin-left: 160px;
  margin-bottom: 10px;
  border-width: 0 1px 1px;
  background: #fff;
  position: relative;
}
.pd05 {
  padding: 10px;
}
.mb20 {
  margin-bottom: 20px;
}
.mr10 {
  margin-right: 10px;
}
.bs06 {
  border: 1px solid #ccc;
}
.mr20 {
  margin-right: 20px;
}

.city_pop .more,
.ico_add,
.ico_add2,
.ico_arrow_rt,
.ico_bound,
.ico_del,
.ico_doubt,
.ico_down,
.ico_download,
.ico_drop,
.ico_gold_medal,
.ico_group,
.ico_mail,
.ico_order_msg,
.ico_order_review,
.ico_order_submit,
.ico_order_travel,
.ico_pass,
.ico_preview,
.ico_print,
.ico_print2,
.ico_refund2,
.ico_return,
.ico_tips1,
.ico_tips2,
.ico_warn,
.ico_warn3,
.ico_warn4,
.jmp_info i,
.more_down,
.more_up,
.orderoff_print02,
.password_info {
  display: inline-block;
  background-image: url('../assets/images/un_16x16.png');
  background-position: 0 -9999em;
  background-repeat: no-repeat;
}
.clearfix,
.s_box2,
.sidenav {
  zoom: 1;
}
.ico_download {
  color: #0066cf;
  background-position: 0 -158px;
}
.ico_download,
.ico_group,
.ico_print {
  padding-left: 20px;
  display: inline-block;
}
.box-invoice .li_btn .button,
.box_hd,
.box_hd2,
.btn_cancel,
.button,
.dropdown .curr,
.dropdown .dd_list span,
.filter_tab li,
.form2 .ico_warn3,
.ico_arrow_rt,
.ico_download,
.ico_drop,
.ico_refund2,
.ico_tips1,
.tab01 li,
.tabli,
.tooltip .delete {
  cursor: pointer;
}
.fr {
  float: right;
}
.ico_tips2 {
  width: 16px;
  height: 16px;
  margin-right: 5px;
  background-position: 0 -654px;
  vertical-align: text-bottom;
}
.clearfix:after,
.s_box2:after,
.sidenav:after {
  display: block;
  clear: both;
  visibility: hidden;
  height: 0;
  content: '.';
}
.adbox,
.breadcrumb,
.clearfix:after,
.grade_box,
.l_btn01 span,
.links_list,
.mc_acount,
.mc_acount .cn,
.mc_acount .cn p.wrap,
.mc_info,
.mc_info_detail,
.mc_service dl dd,
.ovh,
.pb_wrapper,
.process_bar,
.row32,
.row62,
.s_box2:after,
.s_tab,
.sidenav .ico_arr,
.sidenav:after {
  overflow: hidden;
}
.order_tab_box {
  position: relative;
  height: 39px;
  border-bottom: 2px solid #2577e3;
  .order_tab {
    height: 39px;
    a {
      float: left;
      margin-right: 5px;
      width: 138px;
      height: 37px;
      line-height: 37px;
      border: 2px solid #ccc;
      border-bottom: 0 none;
      font-family: Microsoft Yahei;
      font-size: 18px;
      color: #666;
      text-align: center;
      &.current,
      &.current:hover {
        position: relative;
        top: 2px;
        margin-top: -2px;
        height: 39px;
        border-color: #2577e3;
        background-color: #fff;
        color: #06c;
        cursor: default;
      }
    }
  }
  .mod_sort {
    position: absolute;
    right: 0;
    bottom: 7px;
    top: 5px;
  }
}
.w160 {
  width: 160px;
}
.t_body {
  font-family: Microsoft YaHei, Tahoma, SimSun, Verdana, Arial, sans-serif;
  .order-items {
    margin: 10px 0 10px 28px;
    height: 100px;
  }
  .order-info {
    max-width: 720px;
    float: left;
  }
  .order-item {
    float: left;
  }
  .item {
    height: 200px;
    .order-item-title {
      font-size: 16px;
      line-height: 20px;
      color: #111;
      font-weight: 700;
      margin-bottom: 6px;
    }
    .order-item-txt {
      font-size: 12px;
      line-height: 16px;
      color: #333;
      margin-bottom: 6px;
    }
    .order-price-group {
      float: right;
      text-align: right;
      font-size: 0;
      margin-right: 12px;
      .order-price-detail {
        display: inline-block;
        vertical-align: top;
        border-right: 1px solid #d8d8d8;
        padding-right: 7px;
        margin-right: 7px;
      }
      .order-price-num {
        color: #e56700;
        font-size: 16px;
        line-height: 20px;
        vertical-align: middle;
        font-weight: 700;
      }
      .order-price-status {
        display: inline-block;
        vertical-align: top;
      }
      .order-price-status-title {
        font-size: 16px;
        line-height: 20px;
        color: #666;
      }
    }
    .btns {
      margin: 0 12px 12px 0;
      text-align: right;
      .btn {
        margin-left: 20px;
        display: inline-block;
        width: 92px;
        line-height: 12px;
        font-size: 12px;
        padding: 8px 0;
        border-radius: 4px;
        background: 0 0;
        text-align: center;
        cursor: pointer;
        border: 1px solid #609eef;
        span {
          color: #2477e3;
          display: block;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
          max-width: 220px;
          padding: 0 5px;
        }
        p {
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: pre;
        }
      }
    }
  }
}
.orders_list {
  .item {
    border: 1px solid #d9d9d9;
    position: relative;
    margin-bottom: 10px;
  }
  h3 {
    font-family: Tahoma;
    font-weight: 400;
    color: #333;
    padding-left: 10px;
    padding-top: 8px;
    height: 26px;
    background-color: #f6f6f6;
    .base_label {
      vertical-align: middle;
      border-bottom: 1px solid transparent;
      cursor: pointer;
      input {
        margin: -4px 3px 0 0;
        overflow: hidden;
        border: none;
        font-family: Arial;
        vertical-align: middle;
      }
    }
    .ilb {
      display: inline-block;
      zoom: 1;
    }
    .order-btn {
      color: #06c;
      cursor: pointer;
    }
    .card-order-id {
      color: #06c;
    }
  }
}
.t_foot {
  overflow: hidden;
  zoom: 1;
  .base_label {
    margin: 0 20px 0 10px;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    input {
      margin: -4px 3px 0 0;
      overflow: hidden;
      border: none;
      font-family: Arial;
      vertical-align: middle;
    }
  }
  .ico_download {
    color: #0066cf;
    background-position: 0 -158px;
    padding-left: 20px;
    display: inline-block;
  }
}
.fl {
  float: left;
}
</style>